package imoocvideodev.common.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: Redi
 * @Date: 2021/1/31 12:51
 * @Description: Swagger2配置类
 * @Path: http://localhost:8081/swagger-ui.html
 */
@Configuration
@EnableSwagger2
public class swagger2Config {

    /**
     * @author: Redi
     * @description: swagger2的配置文件，配置扫描包的位置等等
     */
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("src.main.java.imoocvideodev.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * @author: Redi
     * @description: 构建api文档的信息
     */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("使用swagger2构建的短视频后端api接口文档")
                .contact(new Contact("redi","redimail.163.com","https://gitee.com/redicode"))
                .description("欢迎访问短视频接口文档，这里是描述信息~" )
                .build();
    }

}
